package p.sunmes.les.util;

import java.io.IOException;
import java.io.InputStream;

public class DataDecodeInputStream extends InputStream {

	private int p = 0;
	private InputStream in;

	public DataDecodeInputStream(InputStream input) {
		in = input;
	}

	@Override
	public int read() throws IOException {
		int v = in.read();
		if (v == -1) {
			return v;
		}
		v = DataUtil.byte2UnsignInt(v);
		v = v + 0xF - p % 0xF;
		p++;
		return (byte) v;
	}

}
